rush-resolver-cache-plugin: add pnpm 10 / lockfile v9 compatibility#5749
Open
rush-resolver-cache-plugin: add pnpm 10 / lockfile v9 compatibility#5749
Conversation
6034479 to
3ff472b
Compare
dmichon-msft
reviewed
Apr 7, 2026
rush-plugins/rush-resolver-cache-plugin/src/test/__snapshots__/helpers.test.ts.snap
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/test/helpers.test.ts
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/afterInstallAsync.ts
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/afterInstallAsync.ts
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/afterInstallAsync.ts
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/computeResolverCacheFromLockfileAsync.ts
Outdated
Show resolved
Hide resolved
rush-plugins/rush-resolver-cache-plugin/src/computeResolverCacheFromLockfileAsync.ts
Outdated
Show resolved
Hide resolved
- Hoist regexes in depPathToFilename to module-level constants - Unify v6/v9 branches in getDescriptionFileRootFromKey using offset - Check specifier against packages list instead of regex heuristic - Extract detectV9Lockfile helper (iterates with early return, no clone) - Store version on IResolverContext when parsing lockfile keys - Extract getStoreIndexPath helper in afterInstallAsync - Use context.version instead of .split() on hot path - Fix undefined in snapshot test names Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dmichon-msft
approved these changes
Apr 8, 2026
| const dir: string = `${pnpmStoreDir}${hashDir}/`; | ||
| const filePrefix: string = `${hashRest}-`; | ||
| try { | ||
| const files: string[] = readdirSync(dir); |
Contributor
There was a problem hiding this comment.
Use { withFileTypes: true } and only match files.
| * or inspecting the first non-file package key. | ||
| */ | ||
| function detectV9Lockfile(lockfile: PnpmShrinkwrapFile): boolean { | ||
| const majorVersion: number | undefined = (lockfile as { shrinkwrapFileMajorVersion?: number }) |
Contributor
There was a problem hiding this comment.
Is the lockfileVersion field not usable?
Member
Author
There was a problem hiding this comment.
dropped support for pnpm 8
Comment on lines
207
to
218
| if (!key.startsWith('file:')) { | ||
| const offset: number = key.startsWith('/') ? 1 : 0; | ||
| const versionAtIndex: number = key.indexOf('@', offset + 1); | ||
| if (versionAtIndex !== -1) { | ||
| if (!name) { | ||
| name = key.slice(offset, versionAtIndex); | ||
| } | ||
| const parenIndex: number = key.indexOf('(', versionAtIndex); | ||
| version = | ||
| parenIndex !== -1 ? key.slice(versionAtIndex + 1, parenIndex) : key.slice(versionAtIndex + 1); | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
Extract this to its own helper and give it unit tests
| return `${filename.substring(0, MAX_LENGTH_WITHOUT_HASH)}_${createBase32Hash(filename)}`; | ||
| export function depPathToFilename(depPath: string, usePnpm10Hashing?: boolean): string { | ||
| let filename: string = depPathToFilenameUnescaped(depPath).replace(SPECIAL_CHARS_REGEX, '+'); | ||
| if (usePnpm10Hashing) { |
Contributor
There was a problem hiding this comment.
Is there an @pnpm package we can import that is lightweight and does this?
Member
Author
There was a problem hiding this comment.
yes. i was avoiding it to avoid bringing in multiple versions of the package for v8 and v10 compat. i'll drop support for v8
- Use readdirSync with { withFileTypes: true } to match only files
- Use lockfile.shrinkwrapFileMajorVersion directly (no cast needed)
- Extract extractNameAndVersionFromKey helper with unit tests
- Add comment explaining why depPathToFilename is inlined vs @pnpm/dependency-path
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add @pnpm/dependency-path as a dependency - Remove custom depPathToFilename, createBase32Hash, createShortSha256Hash, depPathToFilenameUnescaped, and associated regex/hash constants - Remove isV9Lockfile parameter from resolveDependencyKey/resolveDependencies - Remove detectV9Lockfile helper (no longer needed) - Remove unit tests for removed custom hash/filename functions - Update snapshots to reflect pnpm 10 hashing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
add pnpm 10 / lockfile v9 compatibility to rush-resolver-cache-plugin
Details
rush-resolver-cache-plugin does not support v9 pnpm lockfile format
support pnpm lockfile format v9 and update tests for v6 and v9 format.
How it was tested
unit tests and manually tested integration with pnpm 10 repo.
Impacted documentation